package com.lrh.java8;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public class LambdaExpression {
    public static void main(String args[]){

        Comparator<Apple> byColor = new Comparator<Apple>() {
            @Override
            public int compare(Apple o1, Apple o2) {
                return o1.getColor().compareTo(o2.getColor());
            }
        };

        List<Apple> list = Collections.emptyList();

        list.sort(byColor);
        System.out.println(list);
        //jdk8
        Comparator<Apple> byColor2 = (o1, o2) -> o1.getColor().compareTo(o2.getColor());
        List<Apple> list2 = Collections.emptyList();
        list2.sort(byColor2);
        System.out.println(list2);

        Function<String, Integer> flambda = s -> s.length();

        Predicate<Apple> p = (a) -> a.getColor().equals("green");



    }
}
